from easydict import EasyDict


def get_default_config(network_stride = (8,8),ratios = (0.5,1,2),scales = (4,8,16,32) ):
    conf = EasyDict()
    conf.TRAIN = EasyDict()
    conf.TRAIN.RPN_ANCHOR_RATIOS = ratios #h /w = ratio
    conf.TRAIN.RPN_ANCHOR_SCALES = scales

    conf.TRAIN.RPN_BATCH_SIZE = 256
    conf.TRAIN.RPN_NEGATIVE_OVERLAP = 0.3
    conf.TRAIN.RPN_POSITIVE_OVERLAP = 0.7
    conf.TRAIN.RPN_CLOBBER_POSITIVES = False
    conf.TRAIN.RPN_FG_FRACTION = 0.5
    conf.TRAIN.RPN_BBOX_WEIGHTS = [1.0,1.0,1.0,1.0]
    conf.TRAIN.RPN_PRE_NMS_TOP_N = 6000
    conf.TRAIN.RPN_POST_NMS_TOP_N = 300
    conf.TRAIN.RPN_NMS_THRESH = 0.7
    conf.TRAIN.RPN_MIN_SIZE = 1 #should not be 0
    #conf.TRAIN.BATCH_IMAGES = 1
    conf.NETWORK_STRIDE = network_stride
    conf.TRAIN.BATCH_ROIS = -1
    conf.TRAIN.FG_FRACTION = 0.25
    conf.TRAIN.FG_THRESH = 0.5
    conf.TRAIN.BG_THRESH_HI = 0.5
    conf.TRAIN.BG_THRESH_LO = 0.0
    conf.TRAIN.BBOX_NORMALIZATION_PRECOMPUTED = True
    conf.TRAIN.BBOX_MEANS = [0,0,0,0]
    conf.TRAIN.BBOX_STDS = [0.1,0.1,0.2,0.2]
    conf.TRAIN.BBOX_WEIGHTS = [1.0,1.0,1.0,1.0]
    conf.TRAIN.DIDSPLAY_INTERVAL = 200
    conf.TRAIN.ENABLE_OHEM = True
    conf.TRAIN.BATCH_ROIS_OHEM = 512
    conf.TRAIN.VIZ_RPN = False
    conf.TRAIN_VIZ_ENV = None

    conf.network = EasyDict()
    conf.network.RFCN_ONLY = False
    conf.network.NUM_ANCHORS = len(conf.TRAIN.RPN_ANCHOR_RATIOS) * len( conf.TRAIN.RPN_ANCHOR_SCALES)
    conf.network.RPN_PRE_NMS_TOP_N = conf.TRAIN.RPN_PRE_NMS_TOP_N
    conf.network.RPN_POST_NMS_TOP_N = conf.TRAIN.RPN_POST_NMS_TOP_N

    assert conf.NETWORK_STRIDE[0] == conf.NETWORK_STRIDE[1]
    conf.network.RPN_FEAT_STRIDE = conf.NETWORK_STRIDE[0]
    conf.network.ANCHOR_SCALES = conf.TRAIN.RPN_ANCHOR_SCALES
    conf.network.ANCHOR_RATIOS = conf.TRAIN.RPN_ANCHOR_RATIOS

    conf.dataset = EasyDict()
    conf.dataset.NUM_CLASSES = 2#with background

    conf.pretrained = None
    conf.CLASS_AGNOSTIC = True

    conf.TEST = EasyDict()
    conf.TEST.gpu_id = 0
    conf.TEST.KEEP_THRESHOLD = .7
    conf.viz_env = None
    conf.resume = None
    conf.FIXED_PARAMS = ["conv1","bn_conv1","res2","bn2"]
    return conf
